import { request } from './request'
import { formatDate } from 'assets/common/tool'
// 热门电台
export function _getHotradio (limit, type = 'hot') {
  return request({
    url: '/dj/toplist',
    params: {
      limit: limit,
      type: type
    }
  })
}
// 新晋电台榜
export function _getNewradio (limit, type = 'new') {
  return request({
    url: '/dj/toplist',
    params: {
      limit: limit,
      type: type
    }
  })
}
// 推荐电台
export function _getTodayradio () {
  return request({
    url: '/dj/recommend'
  })
}
// 电台详情
export function _getRadioMes (rid) {
  return request({
    url: '/dj/detail',
    params: {
      rid: rid
    }
  })
}
// 提取电台详情
export class RadioMain {
  constructor (radio) {
    this.picUrl = radio.picUrl
    this.name = radio.name
    this.pic = radio.dj.avatarUrl
    this.nickname = radio.dj.nickname
    this.subCount = radio.subCount
    this.category = radio.category
    this.desc = radio.desc
    this.programCount = radio.programCount
    this.createTime = radio.createTime
  }
}
// 电台节目
export function _getProgress (rid) {
  return request({
    url: '/dj/program',
    params: {
      rid: rid
    }
  })
}
// 提取电台节目的关键信息
export class ProgressMain {
  constructor (progress) {
    this.id = progress.mainSong.id
    this.name = progress.name
    this.artist = progress.dj.nickname
    this.pic = progress.coverUrl
    this.listenerCount = progress.listenerCount
    this.likedCount = progress.likedCount
    this.time = formatDate(new Date(progress.duration), 'mm:ss')
  }
}
// 电台的分类
export function _getRadioType () {
  return request({
    url: '/dj/catelist'
  })
}
// 分类推荐电台
export function _getTypeinfo (id) {
  return request({
    url: '/dj/recommend/type',
    params: {
      type: id
    }
  })
}
// 分类热门电台
export function _getTypeHotInfo (id, limit) {
  return request({
    url: '/dj/radio/hot',
    params: {
      cateId: id,
      limit: limit
    }
  })
}
